package vincent.com.layouttest;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import vincent.com.layouttest.multidex.MultiDex;
import vincent.com.layouttest.util.LogUtil;
import vincent.com.layouttest.util.ReflectHelper;

/**
 * Created by zvin-chen on 17/2/28.
 */

public class DynamicLoadDexActivity extends ColorStatusActivity {
    @Override
    public View onCreateView(ViewGroup rootView) {
        return LayoutInflater.from(this).inflate(R.layout.activity_dynamicloaddex, rootView, true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public void loadDex(View view){
        new Thread(new Runnable() {
            @Override
            public void run() {
                MultiDex.install(DynamicLoadDexActivity.this, MultiDex.MultiDexType.MODULEHELLO);
            }
        }).start();
    }

    public void hello(View view){
        try{
            Class helloCls = Class.forName("com.zvin.test.Hello");

            ReflectHelper.callStaticMethod(helloCls, "main", null, null);
        }catch (ClassNotFoundException e){
            LogUtil.e("czw", "ClassNotFoundException--->" + e.getMessage());
        }catch (Exception e){
            LogUtil.e("czw", "Exception--->" + e.getMessage());
        }
    }
}
